package com.h.heal.controller;

import com.h.heal.entity.Admin;
import com.h.heal.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    private AdminService adminService;

    @RequestMapping("/login")
    @ResponseBody
    public String login(Admin admin, HttpSession httpSession) {
        return adminService.login(admin, httpSession);
    }



    @RequestMapping("/logout")
    public String logout(HttpSession session){
        session.invalidate();  //设置session失效
        return "redirect:/html/welcome/welcome.html";  //重定向到登录页面
    }
}
